package com.wocai.jrt.orgadmin.stats.action;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wocai.jrt.orgadmin.stats.bean.PerFormReqBean;
import com.wocai.jrt.orgadmin.stats.service.spi.InvestorStatsService;
import com.wocai.jrt.orgadmin.utils.UserUtils;

/**
 * 投资人统计控制器
 * @author zhangyz
 * @date 2015年9月24日13:33:40
 */
@Controller
@RequestMapping("/investorStats")
public class InvestorStatsAction {
	private static final Logger LOGGER = LoggerFactory.getLogger(InvestorStatsAction.class);
	@Inject
	private InvestorStatsService investorStatsServiceImpl;
	/**
     * 跳转至投资人统计
     * @param model 参数 
     * @return 预约单List
     */
    @RequestMapping("/statsPage")
    public String invesStats(PerFormReqBean model, Map<String, Object> maps) {
        return "stats/performStats/invesStats";
    }
    
    /**
     * 测试缓存
     */
    @RequestMapping("/cache")
    public void testCache(){
    	//计算投资人统计数据
    	investorStatsServiceImpl.statsAllOrgInvestorInfo();
    }
    
    /**
	 * 获取投资人统计数据
	 * @param model 参数
	 * @return 预约单List
	 */
	@ResponseBody
	@RequestMapping("/queryData")
	public Map<String, Object> queryData( PerFormReqBean model) {
		Map<String, Object> result = new HashMap<String, Object>();
    	try {
			model.setOrgId(UserUtils.getOrgId());
			Map<String, Object> map = investorStatsServiceImpl.getDemandCache(UserUtils.getOrgId());
			result.put("data", map);
		} catch (Exception e) {
			e.printStackTrace();
			LOGGER.error("investorStats data query error, msg=[{}]", e.getMessage());
		}
        return result;
	}
}
